// import { Socket } from "net";

// 初始化数据
export function initData(){
    // 124.88.116.204:9092 192.168.1.94

    // const socket = window.io.connect("http://124.88.116.204:9092?type=2",{transports:['websocket','xhr-polling','jsonp-polling']}); // ,{transports:['websocket','xhr-polling','jsonp-polling']}
    const socket = window.io.connect(`${this.$store.state.wsServer}?type=3`,{transports:['websocket','xhr-polling','jsonp-polling']}); // ,{transports:['websocket','xhr-polling','jsonp-polling']}

    let firstconnect = true;

    // 连接状态
    socket.on('connect', (msg) => { 
        console.log('连接成功');
        console.log(msg);
        socket.emit('clientMsg',JSON.stringify({msgContent:'我很好的，是的'}));
    });initData
    socket.on('disconnect', function(){ console.log("连接失败"); });
    socket.on('connectReply',function(data){ console.log(data) })

    // 接收连接信息
    socket.on("epaperLoadState", message => {
        console.log(message);
        window.location.reload();
        // debugger
        // this.message = message;
        // this.addData(message);
    });

    // 
}

// 检测当前数组长度 是否超过20 
export function checkArrayLength(){
    if(this.tableData.length >= 20){
        this.tableData = this.tableData.slice(0,20);
    }
}
